#include<iostream>
#include<string>
using namespace std;

class Dog
{
    public:
        int weight; 
        /*重载运算符*/
        Dog operator+(const Dog &d){
            Dog dog;
            dog.weight = this->weight + d.weight;
            return dog;
        }
};

int main()
{
    Dog dog1;
    Dog dog2;
    Dog dog3;

    dog1.weight = 10;
    dog2.weight = 20;
    dog3 = dog1 + dog2;
    cout<<"第三只狗狗到体重为："<<dog3.weight<<endl;
    return 0;
}

/*
运行结果为：
    第三只狗狗到体重为：30
    重载运算符“+”，可以把两个对象进行相加。在普通的算术运算符“+”是不能将两个对象进行相加的，所以我们重载运算符的意义可以体现在这里。
*/